package com.ssm.curd.controller;

import com.ssm.curd.bean.Department;
import com.ssm.curd.service.DepartmentService;
import com.ssm.curd.tools.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * DeptController
 * 控制层
 * @author zjl
 * @date 2019/12/5
 */
@RestController
@RequestMapping("/dept")
public class DepartmentController {

    private final DepartmentService departmentService;

    @Autowired
    public DepartmentController(DepartmentService departmentService) {
        this.departmentService = departmentService;
    }

    @RequestMapping("/list")
    public Result getDeptList(){
        List<Department> list = departmentService.getAll();
        return Result.success().add("deptList",list);
    }
}
